<?php
namespace app\login\controller;
use app\login\model\LoginModel;
use think\Controller;
use think\Session;
use think\Request;

class Login extends Controller
{
    /**
	* 登录
	*/
	public function login()
    {
		if(request()->isPost())
		{
			try{
				$info = Request::instance()->param();
				return json(LoginModel::login($info));
			}catch (\Exception $e){
				return json(back(config('state.STATUS_CODE_FOURONE'),$e->getMessage()));
			}
		}
		return $this->fetch();
	}
	/**
	* 退出操作
	*/
	public function outlogin()
    {
	   Session::delete('admin');
	   $this->redirect(url('login/login/login'));
    }
}
